from web.ais.TengXunYuanBao import FileOperate
from django.http import JsonResponse
from web.apis.ToolsUpdate import public_upload_file

TengXunYuanBaoFileOperate = FileOperate.FileOperate()

# 上传文件
def upload_file(request):
    file_data = request.FILES.get('file')
    file_path = public_upload_file(file_data, 'user_update_file')
    # 获取文件大小
    file_size = file_data.size
    # 获取文件名
    file_name = file_data.name
    response = TengXunYuanBaoFileOperate.upload_file(file_path,  file_size)
    return JsonResponse(response, safe=False)